package com.taoge.p4.common.constants;

/**
 * 管理员信息上下文
 */
public class SysUserContext {
    private static ThreadLocal<SysUserInfo> sysUserThreadLocal = new ThreadLocal<>();


    public static void set(SysUserInfo sysUserInfo) {
        sysUserThreadLocal.set(sysUserInfo);
    }

    public static SysUserInfo get() {
        return sysUserThreadLocal.get();
    }

    public static Long getUserId() {
        SysUserInfo sysUserInfo = sysUserThreadLocal.get();
        if (sysUserInfo == null) {
            return null;
        }
        return sysUserInfo.getId();
    }

    public static void remove() {
        sysUserThreadLocal.remove();
    }
}
